package com.cool.modules.finance.controller.admin;

import cn.hutool.core.convert.Convert;
import cn.hutool.json.JSONObject;
import com.cool.core.annotation.CoolRestController;
import com.cool.core.base.BaseController;
import com.cool.core.request.R;
import com.cool.modules.finance.dto.UserFamilyListRequest;
import com.cool.modules.finance.dto.UserFamilyRequest;
import com.cool.modules.finance.entity.family.FinanceFamilyEntity;
import com.cool.modules.finance.service.family.FinanceFamilyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;


@Tag(name = "家庭分组", description = "家庭分组")
@CoolRestController(api = { "add", "delete", "update", "list","page" })
public class AdminFinanceFamilyController extends BaseController<FinanceFamilyService, FinanceFamilyEntity> {
    @Override
    protected void init(HttpServletRequest request, JSONObject requestParams) {

    }


    @Operation(summary = "添加用户家庭信息", description = "添加用户家庭信息")
    @PostMapping("/addUserFamily")
    public R addUserFamily(@RequestBody UserFamilyRequest body) {
        return R.ok(this.service.addUserFamily(body));
    }

    @Operation(summary = "家庭用户列表", description = "家庭用户列表")
    @PostMapping("/listUserFamily")
    public R listUserFamily(@RequestBody UserFamilyListRequest body) {
        return R.ok(this.service.listUserFamily(body));
    }

    @Operation(summary = "家庭用户列表删除", description = "家庭用户删除")
    @PostMapping("/deleteUserFamily")
    public R deleteUserFamily( @RequestBody Map<String, Object> params) {
        return R.ok(this.service.deleteUserFamily(Convert.toLongArray(getIds(params))));
    }


}
